package com.td.module.equipment.framework.core;

import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zhanghe
 * @date 2023/4/16
 */

@Component
public class MqttCallBackContext {

    private final ConcurrentHashMap<String, AbsMqttCallBack> callBackConcurrentHashMap = new ConcurrentHashMap<>();


    public MqttCallBackContext(Map<String, AbsMqttCallBack> callBackMap) {
        this.callBackConcurrentHashMap.clear();
        callBackMap.forEach((k, v) -> this.callBackConcurrentHashMap.put(k, v));
    }

    public AbsMqttCallBack getCallBack(String clientId) {
        return this.callBackConcurrentHashMap.get(clientId);
    }

}
